var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'root',
  password : '123456',
  database : 'node'
});
 
connection.connect();
 
var  sql = 'SELECT * FROM didi';
var  addsql='INSERT INTO didi(Id,name) VALUES(0,?)'
var  num=["mei"]
var  ch='UPDATE didi SET name = ? WHERE Id = ?'
var  chnum=["zhaohan2",5]
var delSql = 'DELETE FROM didi where id=?';
var delnum=[9]
//查
connection.query(sql,function (err, result) {
        if(err){
          console.log('[SELECT ERROR] - ',err.message);
          return;
        }
 
       console.log('--------------------------SELECT----------------------------');
       console.log(result);
       console.log('------------------------------------------------------------\n\n');
    })
//增
connection.query(addsql,num,function(err,ins){
    if(err){
        console.log('[INSERT ERROR] - ',err.message);
        return;
    }

})
connection.query(ch,chnum,function(err,updata){
    if(err){
        console.log('[UPDATA ERROR] - ',err.message);
        return;
      }
      console.log('--------------------------UPDATE----------------------------');
      console.log('UPDATE affectedRows',updata.affectedRows);
      console.log('-----------------------------------------------------------------\n\n');
})
connection.query(delSql,delnum,function(err,del){
    if(err){
        console.log('[DELETE ERROR] - ',err.message);
        return;
      }
})